//
//  ZZCustomViewModel.m
//  新项目
//
//  Created by liGordon on 17/3/14.
//  Copyright © 2017年 刘耀宗. All rights reserved.
//

#import "ZZCustomViewModel.h"

@implementation ZZCustomViewModel


+(instancetype)shareViewModel{
    static id instance;
    static  dispatch_once_t once;
    dispatch_once(&once, ^{
        instance=[[self alloc] init];
    });
    return instance;
    
}

-(void)getCustomConvertAnalysisWithCompanyID:(NSString *)companyID andPageIndex:(NSString *)pageIndex andPageSize:(NSString *)pageSize andRecommendName:(NSString *)RecommendName andSuccess:(void (^)(NSDictionary *))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"companyid" forValue:companyID];
    [strDic setKey:@"pageSize" forValue:@"10"];
    [strDic setKey:@"pageIndex" forValue:pageIndex];
    [strDic setKey:@"RecommendName" forValue:RecommendName];
    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpReporting/Data/GetTurnCustomer" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];

}

-(void)getNewCustomConvertAnalysisWithCompanyID:(NSString *)companyID andPageIndex:(NSString *)pageIndex andPageSize:(NSString *)pageSize andStartTime:(NSString *)startTime andEndTime:(NSString *)endTime andSuccess:(void (^)(NSDictionary *))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"companyid" forValue:companyID];
    [strDic setKey:@"pageSize" forValue:@"10"];
    [strDic setKey:@"pageIndex" forValue:pageIndex];
    [strDic setKey:@"StartTime" forValue:startTime];
    [strDic setKey:@"EndTime" forValue:endTime];

    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpReporting/Data/GetNewAddCustomer" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];
}

-(void)getCarLostAnalysisWithCompanyID:(NSString *)companyID andPageIndex:(NSString *)pageIndex andPageSize:(NSString *)pageSize andNum:(NSString *)num andSuccess:(void (^)(NSDictionary *))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"companyid" forValue:companyID];
    [strDic setKey:@"pageSize" forValue:pageSize];
    [strDic setKey:@"pageIndex" forValue:pageIndex];
    [strDic setKey:@"Num" forValue:num];

    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpReporting/Data/CarLossCustomer" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];
}


-(void)getBeautyOrRepairBigFansWithCompanyID:(NSString *)companyID andPageIndex:(NSString *)pageIndex andPageSize:(NSString *)pageSize andParam1:(NSString *)param1 andParam2:(NSString *)param2 andType:(NSString *)type andTxtbegin:(NSString *)txtbegin andTxtEnd:(NSString *)txtEnd andName:(NSString *)name andPlateNumber:(NSString *)plateNumber andSuccess:(void (^)(NSDictionary *))success andFailer:(void (^)())failer
{
    NSMutableDictionary *strDic = [NSMutableDictionary dictionary];
    [strDic setKey:@"Param1" forValue:param1];
    [strDic setKey:@"Param2" forValue:param2];
    
    [strDic setKey:@"companyid" forValue:companyID];
    [strDic setKey:@"pageSize" forValue:pageSize];
    [strDic setKey:@"pageIndex" forValue:pageIndex];

    [strDic setKey:@"type" forValue:type];
    [strDic setKey:@"txtbegin" forValue:txtbegin];
    [strDic setKey:@"txtend" forValue:txtEnd];
    [strDic setKey:@"name" forValue:name];
    [strDic setKey:@"PlateNumber" forValue:plateNumber];
    
    NSString *jsonStr=[WHJSON jsonStringWithObject:strDic];
    
    NSMutableDictionary *dic=[NSMutableDictionary dictionary];
    [dic setKey:@"data" forValue:jsonStr];
    
    [YBHttpTool post:@"api/CmpReporting/Data/CarZSCustomer" params:dic success:^(NSDictionary *obj) {
        DLog(@"=====%@",obj);
        if ([obj isKindOfClass:[NSNull class]] || obj==nil) {
            DLog(@"返回值为空");
            return ;
        }
        success(obj);
        
    } failure:^(NSError *error) {
        DLog(@"%@",error);
        failer();
    }];
}



@end
